#include <iostream>
#include <stack>
using namespace std;

typedef unsigned long long ull;

const int N = 1e6 + 10;

int top;

ull st[N];

int main()
{
    int n;
    cin >> n;
    while(n--){
        int m;
        cin >> m;
        top = 0;
        while(m--){
            string op;
            cin >> op;
            if(op == "push"){
                ull x;
                cin >> x;
                st[++top] = x;
            }else if(op == "pop"){
                if(top > 0){
                    top--;
                }else{
                    cout << "Empty" << endl;
                }
            }else if(op == "query"){
                if(top > 0){
                    cout << st[top] << endl;
                }else{
                    cout << "Anguei!" << endl;
                }
            }else if(op == "size"){
                cout << top << endl;
            }
            
        }


    }


    return 0;
}
